<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>
<body>
  <div id="test"></div>

  <script src="../js/react.development.js"></script>
  <script src="../js/react-dom.development.js"></script>
  <script src="../js/babel.min.js"></script>

  <script type="text/babel">
    // 创建虚拟dom  jsx
    class Weather extends React.Component {

      state = {isHot: true, wind: '微风'}

      render () {
        const {isHot,wind} = this.state
        return <h1 onClick={this.changeWeather}>今天天气很{isHot? '炎热':'寒冷'}, {wind}</h1>
      }

      // 自定义方法：赋值语句+箭头函数
      changeWeather = () => {
        const isHot = this.state.isHot
        this.setState ({ isHot: !isHot})
      }
    }
    // 渲染到页面
    ReactDOM.render (<Weather/>, document.getElementById ('test'))


  </script>
</body>
</html>